const mongoose = require("mongoose");
const { port, dataBase } = require('../config/dbconfig')

const mongoConnect = async () => {
  await mongoose
    .connect(`mongodb://${port}/${dataBase}`, { useNewUrlParser: true })
    .then(() => {
      console.log("数据库连接成功");
    })
    .catch((err) => {
      console.log("数据库连接失败", err);
    });
};

module.exports = mongoConnect;
